<template>
  <header class="header">
      <h1>todos</h1>
      <input class="new-todo" placeholder="请输入任务名称" autofocus  v-model.trim="uname" @keyup.enter="add"/>
    </header>
</template>

<script>
export default {
  name: 'TodoHeader',
  props: {},
  data(){
    return{
      uname:''
    }
  },
  methods:{
      add(){
        if(!this.uname.length) return
         this.$emit('add',this.uname)
         this.uname=''
      }
  }
}
</script>

<style scoped lang="less"></style>
